class playBoy {
  constructor(name) {
    this.name = name;
    this.task = [];
    setTimeout(() => {
      this.next();
    }, 0);
  }

  sayHi() {
    this.task.push(() => {
      console.log("我是" + this.name);
      this.next();
    });
  }

  play(game) {
    this.task.push(() => {
      console.log("我在玩" + game);
      this.next();
    });
  }

  sleep(time) {
    this.task.push(() => {
      setTimeout(() => {
        console.log("静默");
        this.next();
      }, time);
    });
  }
  next() {
    const fn = this.task.shift();
    fn && fn();
  }
}



const a = 3;

function fn(b) {
  b = b + 1;
  console.log(b);
}

fn(a);
console.log(a);

var name = "章三";

function foo() {
  console.log(this.name);
}

let obj = {
  name: "ck",
  fn: foo,
};

foo();
obj.fn();

let obj1 = {
  name: "ck",
  fn: () => {
    console.log(this.name);
  },
};

obj1.fn();

let func = function () {
  let name = 111;
  console.log("function", this.name);
  arrFunction = () => {
    console.log("==>", this.name);
  };
  arrFunction();
};

func();
